<template>
  <div class="carousel-arrow" :class="'carousel-arrow_' + position">
    <i class="iconfont" :class="'icon-arrow_' + position" v-if="position === 'top' || position === 'left'" :style="{ fontSize: size + 'px' }"></i>
    <span class="carousel-arrow_text">{{ text }}</span>
    <i class="iconfont" :class="'icon-arrow_' + position" v-if="position === 'right' || position === 'bottom'" :style="{ fontSize: size + 'px' }"></i>
  </div>
</template>

<script>
export default {
  name: 'CarouselArrow',
  props: {
    position: { // 指向哪个方向的箭头
      type: String,
      default: 'right'
    },
    text: {
      type: String,
      default: ''
    },
    size: {
      type: Number,
      default: 16
    }
  }
}
</script>

<style lang="less">
.carousel-arrow {
  position: absolute;
  z-index: 10;
  cursor: pointer;
  text-align: center;
  color: white;
  transition: color .3s;

  &:hover {
    color: #FBB03B;
  }

  .iconfont {
    vertical-align: middle;
  }
}
.carousel-arrow_text {
  vertical-align: middle;
}

.carousel-arrow_left {
  top: 50%;
  left: 30px;
  transform: translateY(-50%);

  .carousel-arrow_text {
     margin-left: -5px;
  }
}
.carousel-arrow_right {
  top: 50%;
  right: 30px;
  transform: translateY(-50%);

  .carousel-arrow_text {
     margin-right: -5px;
  }
}
.carousel-arrow_bottom {
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);

  .carousel-arrow_text {
     margin-bottom: 2px;
     display: block;
  }
}
.carousel-arrow_top {
  left: 50%;
  top: 30px;
  transform: translateX(-50%);

  .carousel-arrow_text {
     margin-top: 2px;
     display: block;
  }
}
</style>
